# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libsoup
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.74.3
pkgrel=1
pkgdesc="HTTP client/server library (mingw-w64)"
arch=(any)
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://wiki.gnome.org/Projects/libsoup"
msys2_references=(
  "cpe: cpe:/a:gnome:libsoup"
)
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-cc")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-glib-networking"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-libpsl"
         "${MINGW_PACKAGE_PREFIX}-brotli"
         "${MINGW_PACKAGE_PREFIX}-sqlite3")
source=("https://download.gnome.org/sources/${_realname}/${pkgver:0:4}/${_realname}-${pkgver}.tar.xz")
sha256sums=('e4b77c41cfc4c8c5a035fcdc320c7bc6cfb75ef7c5a034153df1413fa1d92f13')
msys2_repository_url="https://gitlab.gnome.org/GNOME/libsoup"

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

}

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  CFLAGS+=" -fcommon"  # work around gcc 10 being stricter here
  MSYS2_ARG_CONV_EXCL="--prefix=" \
  meson \
      --prefix="${MINGW_PREFIX}" \
      --buildtype plain \
      --auto-features=enabled \
       -Dgtk_doc=true \
       -Dgssapi=disabled \
       -Dgnome=true \
       -Dtests=false \
       -Dsysprof=disabled \
       --default-library both \
      ../${_realname}-${pkgver}

  meson compile
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  DESTDIR="${pkgdir}" meson install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
